﻿using System.Text;

namespace JT809.GpsRedisConsumer.Common
{
    class HttpUtil
    {
        public static async Task<string> GetStringAsync(string url)
        {
            using var a = new HttpClient();
            return await a.GetStringAsync(url);
        }
        public static async Task<string> PostJsonAsync(string url, string content)
        {
            using var a = new HttpClient();
            using var response = await a.PostAsync(url, new StringContent(content, Encoding.UTF8, "application/json"));
            return await response.Content.ReadAsStringAsync();
        }
        public static async Task<string> PostByteArrayAsync(string url, byte[] content)
        {
            using var a = new HttpClient();
            using var response = await a.PostAsync(url, new ByteArrayContent(content));
            return await response.Content.ReadAsStringAsync();
        }
    }
}
